package example.controller;

import example.utils.Jwt_Auth0_JWTUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * TODO
 *
 * @author zgq
 * @date 2020/10/22 13:35
 */
@RestController
@RequestMapping("/auth")
public class JWT_Auth0_Controller {
    @Autowired
    private Jwt_Auth0_JWTUtil zn_jwtUtil;

    @GetMapping("/createToken/{loginName}")
    public String createToken(@PathVariable("loginName") String loginName) {
        String token = zn_jwtUtil.generateToken(new HashMap<String, Object>(), loginName);
        return token;
    }

    @PostMapping("/verifyToken")
    public Boolean verifyToken(String token, String loginName) {
        return zn_jwtUtil.verifyToken(token);
    }
}
